package com.mengtian_tech.tju.dataquery.api.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.mengtian_tech.tju.dataquery.api.service.AsyncDateService;
import com.mengtian_tech.tju.dataquery.api.service.PersonVisitApplyService;

/**
 * 同步学生申请任务
 * @author wxd56
 *
 */
@Component
public class AsyncPersonApplyTask {

	@Autowired
	AsyncDateService asyncDateService;

	@Autowired
	PersonVisitApplyService personVisitApplyService;
	
	@Scheduled(cron = "0 0 7 * * * ")
	public void run() {
		int total = 0;
		int count = personVisitApplyService.aysncPersonVisitApply();
		while(count > 0) {
			total+=count;
			count = personVisitApplyService.aysncPersonVisitApply();
		}
		
		asyncDateService.updateDate("05", total);
	}
	
}
